<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录</title>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/login.css">
    <script type="text/javascript" src="js/jquery.min.js"></script>
</head>

<body>
    <div class="container-login">
        <div class="container-pic">
            <img src="pic/computer.png" width="350px" alt="图片加载失败">
        </div>
        <div class="login-dialog">
            <h3>登录</h3>
            <div class="row">
                <label for="userName"><span>用户名</span></label><input type="text" name="userName" id="userName" class="form-control">
            </div>
            <div class="row">
                <label for="password"><span>密码</span></label><input type="password" name="password" id="password" class="form-control">
            </div>
            <div class="row">
                <button type="button" class="btn btn-info btn-lg" onclick="login()">登录</button>
            </div>
        </div>
    </div>
    <script src="js/jquery.min.js"></script>
    <script>
        function login() {
            $.ajax({
                url:"/user/login",
                type:"post",
                data:{
                    //将输入的数据发送到后端
                    userName:$("#userName").val(),
                    password:$("#password").val()
                },
                //result是从后端接收到的数据
                "success":function (result){
                    if (result.data  === "登陆成功" && result.code === "SUCCESS"){
                        //页面跳转
                        location.href = "/book_list.html?pageNum=1";
                    }else {
                        alert(result.errorMessage);
                    }
                },
            });
        }
    </script>
</body>

</html>